package com.tongji.housediy.view
{
	import com.tongji.housediy.events.commonEvent.RelatedRoomAdminEvent;
	
	import flash.events.MouseEvent;
	import flash.external.ExternalInterface;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	
	import org.robotlegs.mvcs.Mediator;
	
	/**
	 * 
	 * @author yanghanbing
	 * 2011/4/28
	 */ 
	public class ReleaseSuccessMediator extends Mediator
	{
		[Inject]
		public var releaseSuccessView:ReleaseSuccessComp;
		
		public var currentURL:String = "http://space.rryjw.com/Member/Photo/Details.aspx?UserID=43716&PhotoID=2826";
		//public var renrenURL:String = " <a name='xn_share' type='button_count_top' href='#'></a>";
		//public var baishehuiURL:String = ;
		public var image:String = '';
		public var title:String = "test";
		
		override public function onRegister():void
		{ 
			//currentURL = ExternalInterface.call('function(){return document.location.href.toString()}');
			releaseSuccessView.kaixin.addEventListener(MouseEvent.MOUSE_DOWN, shareHandler);
			releaseSuccessView.renren.addEventListener(MouseEvent.MOUSE_DOWN, shareHandler);
			releaseSuccessView.sina.addEventListener(MouseEvent.MOUSE_DOWN, shareHandler);
			releaseSuccessView.tencent.addEventListener(MouseEvent.MOUSE_DOWN, shareHandler);
			releaseSuccessView.baishehui.addEventListener(MouseEvent.MOUSE_DOWN, shareHandler);
			releaseSuccessView.douban.addEventListener(MouseEvent.MOUSE_DOWN, shareHandler);
		}
		
		private function shareHandler(event:MouseEvent):void
		{			
			switch(event.target.id)
			{
				case "kaixinBtn":
					var kaixin:String = "http://www.kaixin001.com/repaste/share.php??title=" + title  + "&rurl=" + currentURL + "&image";
                    navigateToURL(new URLRequest(kaixin), "_blank"); 
					break;
				case "renrenBtn":
					var renren:String = " http://share.renren.com/share/buttonshare.do?link=" + currentURL + "&image";
					navigateToURL(new URLRequest(renren), "_blank"); 
					break;
				case "sinaBtn":
					var sina:String = "http://v.t.sina.com.cn/share/share.php?url=" + currentURL + "&title=" + title + "&image";
					navigateToURL(new URLRequest(sina), "_blank");
					break;
				case "tencentBtn":
					var tencent:String = "http://v.t.qq.com/share/share.php?title=" + title + "&url=" + currentURL + "&pic";
					navigateToURL(new URLRequest(tencent), "_blank");
					break;
				case "baishehuiBtn":
					var baishehui:String = "http://bai.sohu.com/share/blank/add.do?link=" + currentURL;
					navigateToURL(new URLRequest(baishehui), "_blank");
					break;
				case "doubanBtn":
					var douban:String = "http://www.douban.com/recommend/?url=" + currentURL + "&title=" + title;
					navigateToURL(new URLRequest(douban), "_blank");
					break;				
			}				
		}
	}
}